package com.atguigu.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yhl
 * @create 2021-09-27 21:00
 */
@Configuration
public class MyRedissonConfig {

    /**
     * 向容器中放入redissonClient对象
     * @return
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redisson(){
        // 1.创建配置
        Config config = new Config();
        config.useSingleServer().setAddress("redis://121.41.122.204:6379");

        // 2.根据Config创建出RedissonClient实例
        RedissonClient redissonClient = Redisson.create(config);

        return redissonClient;
    }
}
